package cn.ahaiahaixx.supemarketonline.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.ahaiahaixx.supemarketonline.aop.NeedAdminUser;
import cn.ahaiahaixx.supemarketonline.entity.TbAdminUser;
import cn.ahaiahaixx.supemarketonline.model.TbTybeModel;
import cn.ahaiahaixx.supemarketonline.service.TypeService;
import cn.ahaiahaixx.supemarketonline.utils.JsonMessage;

/**
 * 
 * @author Aiden Pearce
 *
 */
@RestController
@RequestMapping("/type")
public class AdminTypeController implements NeedAdminUser {
//登录校验已经完成
  private static final Logger log = LoggerFactory.getLogger(AdminTypeController.class);

  @Autowired
  private TypeService typeService;

  @RequestMapping("/queryAll")
  public JsonMessage queryAll(TbTybeModel model) throws Exception {
    log.debug(String.format("信息:%s", user));
    return typeService.queryAll(model);
  }
  //完成

  @RequestMapping("/add")
  public JsonMessage add(TbTybeModel model) throws Exception {
    return typeService.add(model);
  }
  //{"tbType.typeName":"人类","tbType.typeInfo":"wdnm"}完成
  
  @RequestMapping("/queryByKey")
  public JsonMessage queryByKey(TbTybeModel model) throws Exception {
    return typeService.queryByKey(model);
  }
 // {"tbType.tid":"2"}完成
  
  @RequestMapping("/delete")
  public JsonMessage delete(TbTybeModel model) throws Exception {
    return typeService.delete(model);
  }
  //{"tbType.tid":"2"}完成

  @RequestMapping("/update")
  public JsonMessage update(TbTybeModel model) throws Exception {
    return typeService.update(model);
  }
//{"tbType.tid":"3","tbType.typeName":"test","tbType.typeInfo":"test2","tbType.isEnable":"y"} 成功
  
  @RequestMapping("/undelete")
  public JsonMessage undelete(TbTybeModel model) throws Exception {
    return typeService.undelete(model);
  }
  //成功

  
  // 登录用户信息
  private TbAdminUser user;

  @Override
  public TbAdminUser getUser() {
    return user;
  }

  @Override
  public void setUser(TbAdminUser user) {
    this.user = user;
  }

}
